package de.gwtprime.client.login;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget;

import de.gwtprime.client.ClientFactory;
import de.gwtprime.client.widgets.popup.SocialMediaLoginForm;

/**
 * Represents the login-box
 * @author jan
 *
 */
public class LoginContainer extends Composite {

	interface MyUiBinder extends UiBinder<Widget, LoginContainer> {}
	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

	@UiField Anchor loginButtonGoogle;
	@UiField Label authenticationMessage;

	@UiField Anchor registerBtn;
	
	ClientFactory clientFactory;
	
	public LoginContainer(ClientFactory clientFactory) {
		// sets listBox
		initWidget(uiBinder.createAndBindUi(this));

		this.clientFactory = clientFactory;
	}

	@UiHandler("loginButtonGoogle")
	void handleLoginClickGoogle(ClickEvent e) {
		PopupPanel popup = new PopupPanel();

		popup.add(new SocialMediaLoginForm());
		popup.setGlassEnabled(true);
		popup.setAutoHideEnabled(true);
		popup.setAnimationEnabled(true);
		popup.center();
		popup.show();
		
		
	}
	
	@UiHandler("registerBtn")
	void handleRegisterClickGoogle(ClickEvent e) {
		new RegisterContainer(clientFactory).center();
	}
	
	
}
